import { get, post, put, del } from '@/utils/request'
import type { HealthLog, HealthLogParams, HealthStats } from '@/types/health-log'
import type { Result, PageResult } from '@/types/common'

// 获取健康日志列表
export function getHealthLogList(params: HealthLogParams): Promise<Result<PageResult<HealthLog>>> {
  return get<Result<PageResult<HealthLog>>>('/healthLog/list', params)
}

// 获取健康日志详情
export function getHealthLogDetail(id: number): Promise<Result<HealthLog>> {
  return get<Result<HealthLog>>(`/healthLog/${id}`)
}

// 添加健康日志
export function addHealthLog(data: Partial<HealthLog>): Promise<Result<null>> {
  return post<Result<null>>('/healthLog/add', data)
}

// 更新健康日志
export function updateHealthLog(data: Partial<HealthLog>): Promise<Result<null>> {
  return put<Result<null>>('/healthLog/update', data)
}

// 删除健康日志
export function deleteHealthLog(id: number): Promise<Result<null>> {
  return del<Result<null>>(`/healthLog/delete/${id}`)
}

// 获取用户健康统计数据
export function getUserHealthStats(userId: number): Promise<Result<HealthStats>> {
  return get<Result<HealthStats>>(`/healthLog/stats/${userId}`)
}
